#ifndef _NVMC_HW_H_
#define _NVMC_HW_H_

#include "soc.h"

typedef struct {
	_RW ACR;      /*!< FLASH access control register,   offset: 0x00 */
	_RW KEYR;     /*!< FLASH key register,              offset: 0x04 */
	_RW OPTKEYR;  /*!< FLASH option key register,       offset: 0x08 */
	_OR SR;       /*!< FLASH status register,           offset: 0x0C */
	_RW CR;       /*!< FLASH control register,          offset: 0x10 */
	_RW OPTCR;    /*!< FLASH option control register ,  offset: 0x14 */
	_RW OPTCR1;   /*!< FLASH option control register 1, offset: 0x18 */
} NVMC_Struct;

extern NVMC_Struct SOC_NVMC;

/**
 * Flash访问控制
 */
#define NVMC_ACR_LATENCY_0_7D(val)   ((val)&0x7) /* Flash访问延迟， */
#define NVMC_ACR_PRFTEN              (0x1U<<8)   /* 使能预取 */
#define NVMC_ACR_ICEN                (0x1U<<9)   /* 使能指令缓存 */
#define NVMC_ACR_DCEN                (0x1U<<10)  /* 使能数据缓存 */
#define NVMC_ACR_ICRST               (0x1U<<11)  /* 指令缓存复位，需要先关闭指令缓存 */
#define NVMC_ACR_DCRST               (0x1U<<12)  /* 数据缓存复位，需要先关闭数据缓存 */

#endif /* _NVMC_HW_H_ */
